<?php
chdir("../../");
echo getcwd();
require_once("simpletest/autorun.php");
require_once("simpletest/unit_tester.php");
//require_once '../../data/IRepository.php';
//require_once ('../../data.impl/Repository.php');
//include '../../paramcsts/Param.php';
require_once ('data.impl/ShotDayRepository.php');
require_once 'data.models/ShotDayRepo.php';

	class TestDayShotRepository extends UnitTestCase {
		
		private $connexion;
		private $sdReopId;
		private $shotDayRepository;
		
		
		public function setUp(){
			$this->shotDayRepository = new ShotDayRepository();			
		}
		
		public function AtestGetOBject(){
			$this->sdReopId = "A-85ED";
			$repo = $this->shotDayRepository;
			
			$val = $repo->getObject($this->sdReopId);			
			$this->assertEqual($val->src,"doc/image/day1.jpg");
			$this->assertEqual($val->description,"la description");
			$this->assertEqual($val->city,"");
			$this->assertEqual($val->useruid,"1-M001");			
			
		}
		
		public function testInsertObject(){
			$stRepo = new ShotDayRepo();
			$stRepo->imgid = "A-FDSD";
			$stRepo->src = "doc/image/day1.jpg";
			$stRepo->description = "la description" ;
			$stRepo->city = "";
			$stRepo->country = "";
			$stRepo->useruid = "1-M001";
			$stRepo->tag_first = "test";
			$stRepo->tag_second = "olala";
			$stRepo->tag_third = "OLLE";
			$repo = $this->shotDayRepository;
			
			$val = $repo->insertObject($stRepo);
			$this->assertEqual($val,1);
			
			
		}
		
		public function AtestGetObjectByDate(){
			$year='';
			$month='';
			$day='';
			$uid = '1-M001';
			
			$repo = $this->shotDayRepository;
			$repo->getObjectsByDate($uid,$year,$month,$day);
			$year = 1989;
			$repo->getObjectsByDate($uid,$year,$month,$day);
			$month = 12;
			$repo->getObjectsByDate($uid,$year,$month,$day);
			$day = 14;
			$repo->getObjectsByDate($uid,$year,$month,$day);
			$day='';
			$repo->getObjectsByDate($uid,$year,$month,$day);
			
			
			$this->assertTrue(true);
			
		}
		
		public function testUpdateObject(){
			
		}
		
		public function AtestDeleteObject(){			
			$repo = $this->shotDayRepository;			
			$this->assertTrue($repo->deleteObject("A-45ED"));
			
		}
		
	}
?>